﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Common/Master/PopupDiv.master" AutoEventWireup="true" CodeBehind="Edit.aspx.cs" Inherits="Forum.Web.Admin.UForum.Board.Edit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
 <script type="text/javascript" src="../../Common/Js/tab2.js"></script>
 <style type="text/css">
        .style0
        {
            display:none;
            margin-left: 10px; margin-right: 10px;
            height: 350px; 
            padding-top:5px;
        }
       
        .style1
        {
            text-align:right; padding-right:5px; width:80px;
        }
        .style3
        {
            text-align:right; padding-right:5px; width:70px;
        }
        .style2
        {
            width:130px;
        }
        .style5
        {
            padding:5px 0px 5px 0px;
        }
        label.rightTop
        {
            position: relative;top:-3px;
        }
        input.groupLeft
        {
            position: relative;top:3px;
        }
        .style5 label
        {
            position:relative;top:-3px; margin-left:3px;
        }
        textarea
        {
            width:380px;
        }
    </style>
    <script type="text/javascript">

        //选择整列
        function checkCol(sender, id, container)
        {
            $("#" + container + " :checkbox").each(function (i)
            {
                if ($(this).attr("id").indexOf("_" + id) > -1)
                {
                    if ($(this).attr("checked") != $(sender).attr("checked"))
                    {
                        $(this).attr("checked", $(sender).attr("checked"));
                        check_click(this, container);
                    }
                }
            });
        }

        //选择整行
        function checkRow(sender, id, container)
        {
            $("#" + container + " :checkbox").each(function (i)
            {
                if ($(this).attr("id").indexOf(id + "_") > -1)
                {
                    if ($(this).attr("checked") != $(sender).attr("checked"))
                    {
                        $(this).attr("checked", $(sender).attr("checked"));
                        check_click(this, container);
                    }
                }
            });
        }
        //全部选中
        function checkAll(sender, container)
        {
            $("#" + container + " :checkbox").each(function (i)
            {
                if ($(this).attr("id").indexOf("_") > -1)
                {
                    if ($(this).attr("checked") != $(sender).attr("checked"))
                    {
                        $(this).attr("checked", $(sender).attr("checked"));
                        check_click(this, container);
                    }
                }
            });
        }

        //
        function check_click(sender, container)
        {
            var hid = $("#" + container + " > :hidden");
            if (hid.val() == "")
            {
                hid.val(",");
            }

            if (sender.checked == true)
            {
                hid.val(hid.val() + $(sender).attr("id").substr(2) + ",");
            }
            else
            {
                hid.val(hid.val().replace("," + $(sender).attr("id").substr(2) + ",", ","));
            }
            if (hid.val() == ",")
            {
                hid.val("");
            }
            //alert(hid.val());
        }

        function restore()
        {
            var hid = $("#<%=hidGroupRight.ClientID %>");
            var ids = hid.val().split(",");
            for (var i = 0; i < ids.length; i++)
            {
                if (ids[i] != "")
                {
                    $("#gi" + ids[i]).attr("checked", true);
                }
            }

            hid = $("#<%=hidMemberRight.ClientID %>");
            var ids = hid.val().split(",");
            for (var i = 0; i < ids.length; i++)
            {
                if (ids[i] != "")
                {
                    $("#ui" + ids[i]).attr("checked", true);
                }
            }

        }

        //增加用户
        function addUser()
        {
            if ($("#txtLoginNames").val() == "")
            {
                alert("请输入用户名");
                return;
            }
            $.post("getmember.ashx", { LoginNames: $("#txtLoginNames").val() }, function (data)
            {
                eval("var result = " + data);
                var members = result.Members;
                var notExistMember = result.NotExistMember


                for (var i = 0; i < members.length; i++)
                {

                    if ($("#ur" + members[i].ID).length == 0)
                    {
                        var tr = "<tr>";
                        tr += "<td><input id='ur" + members[i].ID + "' type='checkbox' class='groupLeft' onclick='checkRow(this," + members[i].ID + ",\"userRight\")' /><label  for='ur" + members[i].ID + "'>" + members[i].LoginName + "</label></td>";
                        tr += "<td><input id='ui" + members[i].ID + "_6' type='checkbox' onclick='check_click(this,\"userRight\")' /></td>";
                        tr += "<td><input id='ui" + members[i].ID + "_7' type='checkbox' onclick='check_click(this,\"userRight\")' /></td>";
                        tr += "<td><input id='ui" + members[i].ID + "_8' type='checkbox' onclick='check_click(this,\"userRight\")' /></td>";
                        tr += "<td><input id='ui" + members[i].ID + "_9' type='checkbox' onclick='check_click(this,\"userRight\")' /></td>";
                        tr += "<td><input id='ui" + members[i].ID + "_10' type='checkbox' onclick='check_click(this,\"userRight\")' /></td>";

                        tr += "</tr>";

                        $("#tblUserRight").append(tr);
                    }
                }

                $("#txtLoginNames").val("");

                if (notExistMember != "")
                {
                    alert("用户'" + notExistMember + "'不存在");
                }

                //alert(members.length);
            });
        }

        $(function ()
        {
            $("form").bind("submit", function ()
            {
                var name = $("#<%=Name.ClientID %>").val();
                if (name == "")
                {
                    alert("请输入版块名称");
                    $("#<%=Name.ClientID %>").get(0).focus();
                    return false;
                }
                return true;
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div style="height:10px; line-height:10px;"></div>
    <div id="top_daohang" class="tab2" style="margin-left: 10px; margin-right: 10px;">
        <ul>
            <asp:Repeater ID="rpt" runat="server" EnableViewState="false">
                <ItemTemplate>
                    <li>
                        <div class="menu_l">
                        </div>
                        <div class="menu_r">
                        </div>
                        <a id='lnk_<%#Eval("ID") %>' onclick='setFocus(this)'>
                            <%#Eval("Name") %></a> </li>
                </ItemTemplate>
            </asp:Repeater>
        </ul>
    </div>
    <asp:Panel ID="pnlMain" runat="server">
        <div id="div0" class="tab2_content style0">
            <table cellpadding="0" cellspacing="0" border="0" width="100%" style="">
                <tr>
                    <td class="style1">
                        <span style="color: Red;" id="spanMin">*</span>&nbsp;版块名称：
                    </td>
                    <td class="style2">
                        <asp:TextBox ID="Name" runat="server" CssClass="txt" Width="100px"></asp:TextBox>
                    </td>
                    <td class="style3">
                        上级版块：
                    </td>
                    <td class="style4">
                        <asp:Label ID="lblUpperName" runat="server" Text="Label" Font-Bold="True"></asp:Label><asp:HiddenField
                            ID="UpperID" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td class="style1">
                        当前状态：
                    </td>
                    <td class="style2">
                        <asp:DropDownList ID="State" runat="server" Width="100px">
                        </asp:DropDownList>
                    </td>
                    <td class="style3">
                        版主：
                    </td>
                    <td class="style4">
                        <asp:TextBox ID="Moderator" runat="server" CssClass="txt" Height="19px" Width="170px"
                            ToolTip="用逗号(,)分隔"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style1">
                        版块描述：
                    </td>
                    <td class="style5" colspan="3">
                        <asp:TextBox ID="Remark" runat="server" CssClass="txt" Height="60px" TextMode="MultiLine"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style1">
                        SEO关键字：
                    </td>
                    <td class="style5" colspan="3">
                        <asp:TextBox ID="SeoKeywords" runat="server" CssClass="txt" Height="60px" TextMode="MultiLine"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style1">
                        SEO描述：
                    </td>
                    <td class="style5" colspan="3">
                        <asp:TextBox ID="SeoDescription" runat="server" CssClass="txt" Height="60px" TextMode="MultiLine"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style1">
                        设置：
                    </td>
                    <td class="style5" colspan="3">
                        <asp:CheckBox ID="NeedApprove" runat="server" Text="发贴是否需要审核" />
                        &nbsp;
                        <asp:CheckBox ID="ApplyTopicType" runat="server" Text="是否应用主题类型" />
                    </td>
                </tr>
            </table>
        </div>
        <div id="div1" class="tab2_content style0">
            <div id="groupRight" class="list">
                <asp:HiddenField ID="hidGroupRight" runat="server" />
                <table border="0" cellpadding="0" cellspacing="0" width="100%" id="lvList">
                    <tr>
                        <td>
                            <input id="Checkbox1" type="checkbox" onclick="checkAll(this,'groupRight')" />
                        </td>
                        <asp:Repeater ID="rptRight" runat="server">
                            <ItemTemplate>
                                <td>
                                    <!--group column-->
                                    <input id="gc<%#Eval("ID") %>" type="checkbox" onclick="checkCol(this,<%#Eval("ID") %>,'groupRight')" /><label
                                        for='gc<%#Eval("ID") %>' class="rightTop"><%#Eval("Name") %></label>
                                </td>
                            </ItemTemplate>
                        </asp:Repeater>
                    </tr>
                    <asp:ListView ID="lv" runat="server" EnableViewState="false">
                        <LayoutTemplate>
                            <tr id="itemPlaceholder" runat="server">
                            </tr>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <!--group row-->
                                    <input id="gr<%#Eval("ID") %>" type="checkbox" class="groupLeft" onclick="checkRow(this,<%#Eval("ID") %>,'groupRight')" /><label
                                        for='gr<%#Eval("ID") %>'><%#Eval("Name") %></label>
                                </td>
                                <td>
                                    <!--group item-->
                                    <input id="gi<%#Eval("f0") %>" type="checkbox" onclick="check_click(this,'groupRight')" />
                                </td>
                                <td>
                                    <input id="gi<%#Eval("f1") %>" type="checkbox" onclick="check_click(this,'groupRight')" />
                                </td>
                                <td>
                                    <input id="gi<%#Eval("f2") %>" type="checkbox" onclick="check_click(this,'groupRight')" />
                                </td>
                                <td>
                                    <input id="gi<%#Eval("f3") %>" type="checkbox" onclick="check_click(this,'groupRight')" />
                                </td>
                                <td>
                                    <input id="gi<%#Eval("f4") %>" type="checkbox" onclick="check_click(this,'groupRight')" />
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:ListView>
                </table>
            </div>
        </div>
        <div id="div2" class="tab2_content style0">
            <div style="padding: 10px 10px 0px 10px;">
                增加用户：<input id="txtLoginNames" type="text" style="width: 300px;" class="txt" /><input id="Button1"
                    type="button" value="增加" style="margin-left: 10px;" onclick="addUser()" />
                <span style="color: #aaaaaa">以逗号分隔多个用户</span>
            </div>
            <div class="list" id="userRight">
                <asp:HiddenField ID="hidMemberRight" runat="server" />
                <table border="0" cellpadding="0" cellspacing="0" width="100%" id="tblUserRight">
                    <tr>
                        <td>
                            <input id="Checkbox2" type="checkbox" onclick="checkAll(this,'userRight')" />
                        </td>
                        <asp:Repeater ID="rptUser" runat="server">
                            <ItemTemplate>
                                <td>
                                <!--user column-->
                                    <input id="uc<%#Eval("ID") %>" type="checkbox" onclick="checkCol(this,<%#Eval("ID") %>,'userRight')" /><label
                                        for='uc<%#Eval("ID") %>' class="rightTop"><%#Eval("Name") %></label>
                                </td>
                            </ItemTemplate>
                        </asp:Repeater>
                    </tr>
                    <asp:ListView ID="lvUserRight" runat="server" EnableViewState="false">
                        <LayoutTemplate>
                            <tr id="itemPlaceholder" runat="server">
                            </tr>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <!--group row-->
                                    <input id="ur<%#Eval("ID") %>" type="checkbox" class="groupLeft" onclick="checkRow(this,<%#Eval("ID") %>,'userRight')" /><label
                                        for='ur<%#Eval("ID") %>'><%#Eval("Name") %></label>
                                </td>
                                <td>
                                    <!--group item-->
                                    <input id="ui<%#Eval("f0") %>" type="checkbox" onclick="check_click(this,'userRight')" />
                                </td>
                                <td>
                                    <input id="ui<%#Eval("f1") %>" type="checkbox" onclick="check_click(this,'userRight')" />
                                </td>
                                <td>
                                    <input id="ui<%#Eval("f2") %>" type="checkbox" onclick="check_click(this,'userRight')" />
                                </td>
                                <td>
                                    <input id="ui<%#Eval("f3") %>" type="checkbox" onclick="check_click(this,'userRight')" />
                                </td>
                                <td>
                                    <input id="ui<%#Eval("f4") %>" type="checkbox" onclick="check_click(this,'userRight')" />
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:ListView>
                </table>
            </div>
        </div>
    </asp:Panel>
    <div style="height:20px;"></div>
    <script type="text/javascript">
        //addEvent();
        //initFirstTab(0);
        setFocus(document.getElementById("lnk_0"));
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="保存" />
</asp:Content>
